<?php
require_once (JPATH_LIBRARIES . DS . 'tcpdf' . DS . 'tcpdf.php');
require_once (JPATH_LIBRARIES . DS . 'phpexcel' . DS . 'Classes' . DS . 'PHPExcel.php');

// Register table
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables' . DS);

// Register helper class
JLoader::register('ManagerHelper', dirname(__FILE__) . '/helpers/manager.php');

define('_ES_CSV_DELIMITER', ',');
define('_ES_CSV_QUOTE', '"');

JHTML::_('behavior.modal');
JHTML::_('behavior.calendar');

$controllerName	= JRequest::getWord('c');

$controllerName = ManagerHelper::validateController($controllerName);

switch ($controllerName) {    
	default:
		$controllerName = 'manager';
	case 'pond':
	case 'product':
	case 'fishclass':
	case 'customer':
	case 'config':
	case 'userpim':
	case 'rolepim':
	case 'import':
		
		require_once(JPATH_COMPONENT_ADMINISTRATOR . DS . 'controllers' . DS . $controllerName . '.php');
		$class_name	= 'ManagerController' . $controllerName;
		$controller	= new $class_name();
		
		if (ManagerHelper::validateRolePim($controllerName,JRequest::getVar( 'task' ))) {
			$controller->execute( JRequest::getVar( 'task' ) );
			$controller->redirect();
		} else {
			$controller->execute( JRequest::getVar( 'view' ));
			JError::raiseWarning('', "You don't have this permission!!!");
			$controller->redirect();
		}
}

?>